﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine.UI;
using UnityEngine;
using Assets.Scripts.TDuResource;
using Assets.Scripts.TDu3DWork;

namespace Assets.Scripts.TDuVRUI
{
    class TDuTipPictureDashboard
    {
        public GameObject m_PicturePanel;
        public void create(TDuSceneBaseWorker baseWorker, VariableNode curVarNode, GameObject parent)
        {
            m_PicturePanel = parent.transform.Find("PicturePanel").gameObject;
            m_PicturePanel.SetActive(true);
            parent.SetActive(true);

            GameObject tipPicture = m_PicturePanel.transform.Find("TipPictureWnd").gameObject;
            tipPicture.GetComponent<Image>().sprite = Resources.Load<Sprite>("Scene/Skin/FPC001");

            GameObject Ok_uiButton = m_PicturePanel.transform.Find("Ok_uiButton").gameObject;
            //对话框TipPicture生成
            Ok_uiButton.GetComponent<Button>().onClick.AddListener(
                        () =>
                        {
                            {
                                TDuSceneWorker sceneworker = (TDuSceneWorker)baseWorker;
                                sceneworker.updateMsgVar("", true);
                                m_PicturePanel.SetActive(false);
                                parent.SetActive(false);
                            }
                        }
                    );
        }

        //public void create(VariableNode curVarNode, GameObject parent)
        //{
        //    //对话框TipPicture生成
        //    DefaultControls.Resources panel_uiResources = new DefaultControls.Resources();
        //    GameObject uiPanel = DefaultControls.CreatePanel(panel_uiResources);
        //    uiPanel.name = "PicturePanel";
        //    uiPanel.transform.SetParent(parent.transform, false);
        //    uiPanel.GetComponent<RectTransform>().localScale = new Vector3(0.5f, 0.5f, 0.5f);
        //    uiPanel.GetComponent<Image>().color = Color.gray;
        //    uiPanel.SetActive(false);

        //    DefaultControls.Resources pic_uiResources = new DefaultControls.Resources();
        //    GameObject tipPicture = DefaultControls.CreateImage(pic_uiResources);
        //    tipPicture.transform.SetParent(uiPanel.transform, false);
        //    tipPicture.GetComponent<RectTransform>().sizeDelta = new Vector2(400F, 215F);
        //    tipPicture.name = "TipPictureWnd";
        //    tipPicture.GetComponent<Image>().sprite = Resources.Load<Sprite>("Scene/Skin/FPC001");

        //    DefaultControls.Resources Ok_uiResources = new DefaultControls.Resources();
        //    GameObject Ok_uiButton = DefaultControls.CreateButton(Ok_uiResources);
        //    Ok_uiButton.transform.SetParent(uiPanel.transform, false);
        //    Ok_uiButton.GetComponent<RectTransform>().sizeDelta = new Vector2(200F, 60F);
        //    Ok_uiButton.GetComponent<RectTransform>().anchorMin = new Vector2(0.5F, 0.5F);
        //    Ok_uiButton.GetComponent<RectTransform>().anchorMax = new Vector2(0.5F, 0.5F);
        //    Ok_uiButton.transform.localPosition = new Vector3(0, -240, 0);
        //    Ok_uiButton.transform.Find("Text").GetComponent<Text>().GetComponent<Text>().color = Color.black;
        //    Ok_uiButton.transform.Find("Text").GetComponent<Text>().GetComponent<Text>().text = "确定";
        //    Ok_uiButton.transform.Find("Text").GetComponent<Text>().GetComponent<Text>().fontSize = 40;

        //    Ok_uiButton.GetComponent<Button>().onClick.AddListener(
        //                () =>
        //                {
        //                    {
        //                        uiPanel.SetActive(false);
        //                    }
        //                }
        //            );
        //}
    }
}
